import Image from "../graphics/image"
import Sound from "../media/source"
import Font from "../graphics/font"
export default class loader {
  constructor(data){
    this.data = {}
  }
  transfer(data){
    this.setData(data)
  }
  loadFromSheet(sheet){
    for (var i in sheet) {
      let b = sheet[i]
      switch(b.type){
        case "image":
          this.data[b.id] = new Image(b.path)
          break
        case "sound":
          this.data[b.id] = new Sound(b.path)
          break
        case "font":
          this.data[b.id] = new Font(b.size,b.path)
      }
    }
  }
  setData(data){
    this.data = data
  }
  getRes(id){
    return this.data[id]
  }
}